﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DLL;
using Module;

namespace BLL
{
    public class BUserPassport
    {
        #region 字段

        private DUserPassport APP = new DUserPassport();//数据操作对象
        private static BUserPassport instance;

        #endregion

        #region 公共接口

        /// <summary>
        /// 取得
        /// </summary>
        /// <returns>BUserPassport对象</returns>
        public static BUserPassport getInstance()
        {
            if (instance == null)
            {
                instance = new BUserPassport();
            }
            return instance;
        }
        ///<summary>
        /// 添加
        ///</summary>
        ///<param name="BUserPassport">BUserPassport对象</param>
        public bool Insert(UserPassportInfo userInfo)
        {
            if (userInfo == null || userInfo.UserPassportId.ToString().Length != 18)
                return false;

            try
            {
                return APP.Insert(userInfo);
            }
            catch
            {
                return false;
            }
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="userInfo"></param>
        public bool Update(UserPassportInfo userInfo)
        {
            if (userInfo == null || userInfo.UserPassportId.ToString().Length != 18)
                return false;

            try
            {
                return APP.Update(userInfo);
            }
            catch
            {
                return false;
            }

        }

        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="userPassportId"></param>
        /// <returns></returns>
        public UserPassportInfo GetUserPassportInfo(long userPassportId)
        {

            if (userPassportId == 0 || userPassportId.ToString().Length != 18)
                return null;
            return APP.GetUserPassportInfo(userPassportId);
        }

         /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public UserPassportInfo GetUserPassportInfo(string userName, string password)
        {
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
                return null;

            return APP.GetUserPassportInfo(userName,password);

        }

         /// <summary>
        /// 根据用户名查找用户
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public UserPassportInfo GetUserPassportInfo(string userName)
        {
            if (string.IsNullOrEmpty(userName))
                return null;

            return APP.GetUserPassportInfo(userName);
        }

         /// <summary>
        /// 获取所有用户
        /// </summary>
        /// <returns></returns>
        public List<UserPassportInfo> GetAllUserPassportInfo()
        {
            return APP.GetAllUserPassportInfo();
        }

        /// <summary>
        /// 根据用户状态获取用户列表
        /// </summary>
        /// <param name="status"></param>
        /// <returns></returns>
        public List<UserPassportInfo> GetUserPassportInfoByStatus(int status)
        {
            return APP.GetUserPassportInfoByStatus(status);
        }
        
        #endregion

        public List<UserPassportInfo> GetUserPassportInfoByUserType(int UserType)
        {
            return APP.GetUserPassportInfoByUserType(UserType);
        }
    }
}
